<?php

namespace app\modules\agent\controllers;
use app\models\PointAccount;
use app\models\search\PointChargeSearch;
use Yii;
use app\models\search\PointConsumeSearch;
use app\modules\agent\AdminController;

class PointController extends AdminController
{
    public function actionIndex()
    {
        $pointAccount = PointAccount::getAndCreateObj(Yii::$app->user->id);
        return $this->render('index',[
            'pointAccount'=>$pointAccount,
        ]);
    }
    public function actionHelp()
    {
        return $this->render('help');
    }
    public function actionPointConsumeIndex()
    {
        $searchModel = new PointConsumeSearch();
        $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
        $dataProvider->query->andWhere(['uid'=>Yii::$app->user->id]);

        return $this->render('point-consume-index', [
            'searchModel' => $searchModel,
            'dataProvider' => $dataProvider,
        ]);
    }
    public function actionPointChargeIndex()
    {
        $searchModel = new PointChargeSearch();
        $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
        $dataProvider->query->andWhere(['uid'=>Yii::$app->user->id]);

        return $this->render('point-charge-index', [
            'searchModel' => $searchModel,
            'dataProvider' => $dataProvider,
        ]);
    }

}
